<template>
  <div>
    ID:
    <el-input
      v-model="tableData[0].id"
      placeholder="请输入密码"
      style="width:100px;margin-right:50px"
      :disabled="true"
    ></el-input>
    账号:
    <el-input
      v-model="tableData[0].username"
      style="width:100px;margin-right:50px"
      :disabled="true"
    ></el-input>
    密码:
    <el-input
      v-model="tableData[0].password"
      placeholder="请输入密码"
      style="width:200px;margin-right:50px"
    ></el-input>
    <el-button
      type="success"
      @click="check"
    >提交</el-button>
  </div>
</template>
<script>
export default {
  props: ['id'],
  data: () => ({
    tableData: []
  }),
  async created() {
    const res = await this.$http.getusers()
    res.message.forEach(el => {
      console.log(el)
      if (el.id === Number(this.id)) {
        this.tableData.push(el)
      }
    })
    console.log(this.tableData)
  },
  methods: {
    async check() {
      await this.$http.editusers(Number(this.id), this.tableData[0])
      this.$message({
        message: '编辑成功',
        type: 'success'
      })
      this.$router.go(-1)
    }
  }
}
</script>
<style lang="scss" scoped>
</style>
